class TypedProperty:
    """
    类型约束的描述符
    """
    def __init__(self, name, expected_type):
        self.name = name
        self.expected_type = expected_type
        
    def __get__(self, instance, owner):
        if instance is None:
            return self
        return instance.__dict__.get(self.name, None)
        
    def __set__(self, instance, value):
        if not isinstance(value, self.expected_type):
            raise TypeError(f"Expected {self.expected_type}, got {type(value)}")
        instance.__dict__[self.name] = value
        
    def __delete__(self, instance):
        del instance.__dict__[self.name]

# 使用描述符的类
class Person:
    name = TypedProperty("name", str)
    age = TypedProperty("age", int)
    
    def __init__(self, name: str, age: int):
        self.name = name
        self.age = age

# 使用示例
p = Person("Alice", 30)  # 正常工作
# p.age = "thirty"  # 引发TypeError: Expected <class 'int'>, got <class 'str'>